#if !defined(SAFE_OBEJCT_BIND_IMPL)
#error "this file can only be included by safe_object.hpp"
#else

template <typename FunctorType, typename ParamVecTypes>
struct WrapImpl<FunctorType, ParamVecTypes, PARAM_COUNT>
{
	typedef function_traits<FunctorType> function_traits_type;

	typedef Delegate<boost::function#PARAM_COUNT<typename function_traits_type::result_type, PARAM_TYPE_LIST>, TypeTag, PARAM_COUNT> delegate_type;
};

template <typename ClassType, typename FunctorType PARAM_TYPENAME_LIST>
typename WrapImpl<functorType, typename FilterIfIsNotPlaceholder<typename function_trait<FunctorType>::param_type_vec, boost::mpl::vector<PARAM_TYPE_LIST>>::type, CountPlaceholder<boost::mpl::vector<PARAM_TYPE_LIST>>::velue::_DelegateType
	Bind(FunctorType fn, ClassType *obj PARAM_PASS_LIST) {
	typedef typename FilterIfIsNotPlaceholder<typename function_trait<FunctorType>::param_type_vec, boost::mpl::vector<PARAM_TYPE_LIST>>::type ParamVecType;

	typedef WrapImpl<FunctorType, ParamVecType, boost::mpl::size<ParamVecType>::value>::delegate_type DelegateType;

	return DelegateType(boost::bind(fn, obj PARAM_CALL_LIST), _owner);
}

template <typename ClassType, typename FunctorType PARAM_TYPENAME_LIST>
typename WrapImpl<functorType, typename FilterIfIsNotPlaceholder<typename function_trait<FunctorType>::param_type_vec, boost::mpl::vector<PARAM_TYPE_LIST>>::type, CountPlaceholder<boost::mpl::vector<PARAM_TYPE_LIST>>::velue::_DelegateType
	StaticBind(FunctorType fn, ClassType *obj, const OwnerType &owner PARAM_PASS_LIST) {
	typedef typename FilterIfIsNotPlaceholder<typename function_trait<FunctorType>::param_type_vec, boost::mpl::vector<PARAM_TYPE_LIST>>::type ParamVecType;

	typedef WrapImpl<FunctorType, ParamVecType, boost::mpl::size<ParamVecType>::value>::delegate_type DelegateType;

	return DelegateType(boost::bind(fn, obj PARAM_CALL_LIST), owner);
}

#endif